import { defHttp } from '@/utils/http/axios';
import { listParams, detailParams, createGroupChatParams } from './model/chatGroupModel';
import { BasicListResult, BasicDataResult } from '../model/baseModel';

import { ErrorMessageMode } from '#/axios';

enum Api {
  //Login = '/login',
  list = '/hl/sys/chatGroup/list',
  save = '/hl/sys/chatGroup/createGroupChat',
  edit = '/hl/sys/chatGroup/edit',
  detail = '/hl/sys/chatGroup/detail',
  setDepts = '/hl/sys/chatGroup/setDepts',
}

/**
 * @description: user login api
 */
export function listApi(params: listParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicListResult>(
    {
      url: Api.list,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function createGroupChatApi(
  params: createGroupChatParams,
  mode: ErrorMessageMode = 'modal',
) {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.save,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function editApi(params: createGroupChatParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.edit,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function detailApi(params: detailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.detail,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function setDeptsApi(params: createGroupChatParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.setDepts,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
